//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class DiagramDefinitionHeader : IOfficeXmlSerializable
    {
        private string _uniqueId;
        private string _minVer = Diagram.Serialization.DiagramConstants.DiagramNamespaceUri;
        private string _defStyle;
        private int _resId;
        private List<Name> _titles = new List<Name>();
        private List<Description> _descs = new List<Description>();
        private Categories _catLst;
        private OfficeArtExtensionList _extLst;

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("layoutDefHdr"))
            {
                _uniqueId = c.GetString("uniqueId");
                _minVer = c.GetOptionalString("minVer", Diagram.Serialization.DiagramConstants.DiagramNamespaceUri);
                _defStyle = c.GetOptionalString("defStyle", string.Empty);
                _resId = c.GetOptionalInteger("resId", 0);
                _titles.AddRange(c.ReadOptionalWhile<Name>("title"));
                _descs.AddRange(c.ReadOptionalWhile<Description>("desc"));
                _catLst = c.ReadOptionalElement<Categories>("catLst");
                _extLst = c.ReadOptionalElement<OfficeArtExtensionList>("extLst");


            }

            throw new NotImplementedException();
        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("layoutDefHdr"))
            {



                c.SetOptionalString("uniqueId", _uniqueId, string.Empty);
                c.SetOptionalString("minVer", _minVer, Diagram.Serialization.DiagramConstants.DiagramNamespaceUri);
                c.SetOptionalString("defStyle", _defStyle, string.Empty);
                c.WriteElements(_titles);
                c.WriteElements(_descs);
                c.WriteOptionalElement(_catLst);
                c.WriteOptionalElement(_extLst);
            }


        }
    }
}